package org.wevil.repo;

import org.wevil.entity.cond.CondUserRole;
import org.wevil.entity.pk.PKCondUserRole;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface CondUserRoleRepo extends BaseRepo<CondUserRole, PKCondUserRole> {

    @Query("select roleId from CondUserRole where userId = ?1")
    List<Integer> findRoleIdByUserId(int userId);

    @Query("select userId from CondUserRole where roleId = ?1")
    List<Integer> findUserIdByRoleId(Integer roleId);

    @Modifying
    void deleteByUserId(int userId);

    @Modifying
    void deleteByRoleId(int roleId);

    void deleteByUserIdAndRoleId(Integer userId, Integer roleId);
}
